3.14 sys.monitoring fixes#1
Merged
Erotemic merged 5 commits intoErotemic:update-ci-for-314from Aug 3, 2025
Merged
Conversation
line_profiler/_line_profiler.pyx::_SysMonitoringState.register()
Updated implementation because of side effects of
`sys.monitoring.free_tool_id()` in Python 3.14.0a1+
line_profiler/_line_profiler.pyx
_code_replace()
Now copying the `sys.monitoring` events of the old code object
over
_SysMonitoringState
register()
- Rolled back changes since the last commit;
no longer double-setting the callbacks
- No longer calling `sys.monitoring.free_tool_id()` at all
to avoid unsetting local events
- No longer overwriting the tool name with `'line_profiler'`
if an existing tool is already using
`sys.monitoring.PROFILER_ID`
deregister()
Updated implementation to avoid calling
`sys.monitoring.free_tool_id()`
This was referenced Aug 3, 2025
Erotemic
requested changes
Aug 3, 2025
Owner
Erotemic
left a comment
There was a problem hiding this comment.
Two nitpicks, but otherwise looks good.
Author
|
Ah, just got to those changes but seems like you've already patched those in. Thanks for the review! |
Owner
|
I try to not ask contributors to solve nitpicks that are easy for me to make as a suggestion and then commit myself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
sys.monitoring.free_tool_id()inline_profiler/_line_profiler.pyxbecause it has gained side effects in Python 3.14.__code__of functionsCaveats
This does result in the active tool at
sys.monitoring.PROFILER_IDno longer being overwritten with'line_profiler'if there is an existing profiling tool. But it doesn't impact howLineProfilerfunctions and it's probably better this way.